﻿@{
    ViewBag.Title = "department";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>department</h2>

<link href="@Url.Content("~/Content/themes/style.css?130709")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery.jstree.js")" type="text/javascript"></script>


<div id="department"></div>
<input type="button" id="edit" value="提交" />
<script type="text/javascript" class="source">
    $(function () {

        $("#edit").click(function () {

            var ddd = $("#department").jstree("get_json", -1, ["id", "class", "tag"]);
           //   alert(JSON.stringify(ddd));

            $.ajax({
                url: "/Department/update",
                type: "post",
                data: "data=" + JSON.stringify(ddd),
                success: function (data) {

                    alert(data);

                },
                error: function () {
                }
            });



        });



        $("#department").jstree({
            "json_data": {
                "ajax": {
                    "url": "/data/department",
                    "data": function (n) {

                    }
                }
            },
            "plugins": ["themes", "json_data", "crrm", "contextmenu", "dnd", "ui"]
                                , "core": { "animation": 0 }
        }).bind("loaded.jstree", function (event, data) {
            $("#department").jstree("open_all", $("#department li").eq(0), null, 0);
        })


    });

    //open_all
</script>